﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HamcoWcs.Models.Monitors
{
    public class PconBcrRate : ParaBase
    {
        public static bool IsReadBcrRate { get; set; } = false;

        public static List<PconBcrRate> BcrRates { get; set; } = new List<PconBcrRate>()
        {
            // 码头 1-12
            new PconBcrRate(738,"CJRCV100_BCR_1"),
            new PconBcrRate(742,"CJRCV100_BCR_2"),
            new PconBcrRate(746,"CJRCV200_BCR_1"),
            new PconBcrRate(750,"CJRCV200_BCR_2"),
            new PconBcrRate(754,"CJRCV300_BCR_1"),
            new PconBcrRate(758,"CJRCV300_BCR_2"),
            new PconBcrRate(762,"CJRCV400_BCR_1"),
            new PconBcrRate(766,"CJRCV400_BCR_2"),
            new PconBcrRate(770,"CJRCV100_BCR_R"),
            new PconBcrRate(774,"CJRCV200_BCR_R"),
            new PconBcrRate(778,"CJRCV300_BCR_R"),
            new PconBcrRate(782,"CJRCV400_BCR_R"),
            // 提升机 13-14
            new PconBcrRate(786,"CJMIFB00_BCR"),
            new PconBcrRate(790,"CJMIFB00_BCR"),
            // 3,7口读码器 15-18
            new PconBcrRate(794,"CJMCV300_BCR_R"),
            new PconBcrRate(798,"CJMCV300_BCR_L"),
            new PconBcrRate(802,"CJMCV700_BCR_L"),
            new PconBcrRate(806,"CJMCV700_BCR_R"),
        };

        public PconBcrRate(int index, string name) : base(index, name)
        {
        }

        public ushort ReadCount { get; set; }
        public ushort FaliureCount { get; set; }
        protected override int _len => 4;

        public override void Update(byte[] content)
        {
            var t = GetTargetContent(content);

            ReadCount = Reserve(BitConverter.ToUInt16(t, 0));
            FaliureCount = Reserve(BitConverter.ToUInt16(t, 2));
        }
    }
}
